package com.dxl.web.sysprop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.dxl.common.annotation.RequirePermission;
import com.dxl.common.model.Page;
import com.dxl.common.model.RespData;
import com.dxl.common.utils.Utils;
import com.dxl.entity.sysprop.SysProp;
import com.dxl.service.sysprop.SysPropService;
import com.dxl.web.common.controller.BaseController;

/**
 * 系统属性信息控制器
 * @author 邓小林
 */
@Controller
@RequestMapping("/sysprop")
@RequirePermission(value={"SYSPROP-MODULE"}, name="系统属性模块", desc="包括系统属性增、删、改、查")
public class SysPropController extends BaseController {
	@Autowired
	private SysPropService sysPropService;
	
	@RequestMapping("")
	@RequirePermission(value={"SYSPROP-VIEW"}, name="系统属性查看", desc="查看系统属性信息")
	public ModelAndView sysprop() {
		ModelAndView mv = new ModelAndView("sysprop/list");
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/list")
	@RequirePermission(value={"SYSPROP-VIEW"}, name="系统属性查看", desc="查看系统属性信息")
	public Page<SysProp> list(String keyword, Integer state, Integer page, Integer rows) {
		Page<SysProp> p = this.sysPropService.list(keyword, state, page, rows);
		return p;
	}
	
	@RequestMapping("/edit")
	@RequirePermission(value={"SYSPROP-VIEW"}, name="系统属性查看", desc="查看系统属性信息")
	public ModelAndView edit(String id) {
		ModelAndView mv = new ModelAndView("sysprop/edit");
		if (Utils.isNotBlank(id)) {
			SysProp sysProp = this.baseService.get(SysProp.class, id);
			mv.addObject("entity", sysProp);
		}
		return mv;
	}
	
	@ResponseBody
	@RequestMapping("/save")
	@RequirePermission(value={"SYSPROP-MODIFY"}, name="系统属性修改", desc="修改系统属性信息")
	public RespData save(SysProp sysProp) {
		return sysPropService.save(sysProp);
	}
	
	@ResponseBody
	@RequestMapping("/del")
	@RequirePermission(value={"SYSPROP-DEL"}, name="系统属性删除", desc="删除系统属性信息")
	public RespData del(String[] ids) {
		return sysPropService.del(ids);
	}
	
	@ResponseBody
	@RequestMapping("/state")
	@RequirePermission(value={"SYSPROP-STATE"}, name="系统属性状态修改", desc="修改系统属性状态")
	public RespData state(String[] ids, Integer state) {
		return this.state(SysProp.class, ids, state);
	}
}
